# 读取xlsx文件欸欸容写入b23015135数据库中的data表中
import pymysql
import pandas as pd

# 读取xlsx文件
excel_path = "./旅游攻略搜索结果.xlsx"
data = pd.read_excel(excel_path)
# 连接数据库
conn = pymysql.connect(
    host='10.200.32.179',
    user='root',
    password='111111',
    database='b23015135',
)
cursor = conn.cursor()

for index, row in data.iterrows():
    # 插入数据
    sql = f"INSERT INTO data (title, content,pic) VALUES (%s, %s, %s)"
    cursor.execute(sql, (row['name'], row['english'], row['pic']))
    conn.commit()
cursor.close()
